#include <bits/stdc++.h>
using namespace std;
int h, l, k;
char ch;

int main() {
    cin >> h >> l >> ch >> k;

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= l; j++) {
            if (i == 1 || i == h || j == 1 || j == l || k != 0) {
                cout << ch;
            } else {
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}